/**
 * Created by asus on 2017/4/14.
 */
public class Mydoc {
     static Document d;
    public static void main(String[] args) {
        d = new Document(new IntFactory());
        d.DisplayData();
        d = new Document(new FloatFactory());
        d.DisplayData();
    }
}
// Server Classes
abstract class Data {
    abstract public void DisplayValue();

}
class Integer extends  Data {
    int value;
    Integer() {
        value=100;
    }
    public void DisplayValue(){
        System.out.println (value);
    }
}
class Float extends Data {
    float worth;

    Float() {
        worth = 0.2363F;
    }

    public void DisplayValue() {
        System.out.println(worth);
    }
}

// Pattern Classes
abstract class Factory {
    abstract public Data CreateDataObject();
}
class IntFactory extends Factory {
    public Data CreateDataObject(){
        return new Integer();
    }
}
class FloatFactory extends Factory{
        public Data CreateDataObject(){
            return new Float();
        }


}
//Client classes
class Document {
    Data pd;
    Document(Factory pf){
        pd = pf.CreateDataObject();
    }
    public void DisplayData(){
        pd.DisplayValue();
    }
}
